/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package bl;

import java.awt.BasicStroke;
import java.awt.Graphics2D;
import java.util.LinkedList;
import resources.SpaceColors;

/**
 *
 * @author Alexander
 */
public class BasicPanel extends BasicGraphicElement
{
    private boolean border = false;

    public BasicPanel(float posX, float posY, float width, float height, LinkedList<BasicGraphicElement> childElements) {
        super(posX, posY, width, height, childElements);
    }

    public BasicPanel(float posX, float posY, float width, float height, LinkedList<BasicGraphicElement> childElements, boolean border) {
        super(posX, posY, width, height, childElements);
        this.border = border;
    }
    

    @Override
    public void draw(Graphics2D g2d) 
    {
        g2d.setColor(SpaceColors.getBackgroundColor);
        g2d.fillRect((int)super.getPosX(), (int)super.getPosY(), (int)super.getWidth(), (int)super.getHeight());
        g2d.setColor(SpaceColors.getBasicBorderColor);
        g2d.setStroke(new BasicStroke(5));
        if(border == true)
        {
            g2d.drawRoundRect((int)super.getPosX()+6, (int)super.getPosY()+6, (int)super.getWidth()-14, (int)super.getHeight()-14, 20, 20);
            g2d.setStroke(new BasicStroke(1));
        }
        if(this.getChildElements() != null && !this.getChildElements().isEmpty())
        {
            for(BasicGraphicElement bge : this.getChildElements())
            {
                bge.draw(g2d);
            }
        }
    }

    @Override
    public float getHeight() {
        if(border == true)
        {
           return super.getHeight()-34; 
        }
        return super.getHeight(); 
    }

    @Override
    public float getWidth() {
        if(border == true)
        {
            return super.getWidth()-34;
        }
        return super.getWidth();
    }

    @Override
    public float getPosY() {
        if(border == true)
        {
            return super.getPosY()+16;
        }
        return super.getPosY();
    }

    @Override
    public float getPosX() {
        if(border == true)
        {
            return super.getPosX()+16;
        }
        return super.getPosX();
    }
    
    
}
